-- creates a kind of fogged lens effect for the input.
-- usage: luge soften.lua -o <outputfile> <inputfile>
-- use option -o <output> to specify the output file

-- create a load node and assign the node to a variable:
input_image = node 'gegl:load' {
  path = args[1]
}
-- create a blurred version of the loaded image by applying a
-- gaussian blur filter:
blurred_image = node 'gegl:gaussian-blur' {
  input = input_image
}
-- average the blurred and the unblurred image by summing them
-- up and multiplying by 0.5; this is done here without any
-- intermediate variables. The whole graph is assigned to the
-- variable 'averaged':
averaged = node 'gegl:multiply' {
  -- the input of the multiply is called 'input'.
  input = node 'gegl:add' {
    -- first input of the add-operation is called 'input':
    input = input_image,
    -- second input of the add-operation is called 'aux':
    aux = blurred_image
  },
  -- multiply all pixels with 0.5, ie. take the average of the two added nodes.
  value = 0.5
}

-- clip the averaged image to the size of the input image.
output_image = node 'gegl:crop' (input_image:bounding_box ()) {
  input = averaged
}

-- finally save the image to a new file; the helper method 'save'
-- construct a save node and processes the graph.
if o then
  output_image:save (o[1])
else
  print ("no output option, output not written.")
end
